package cn.bearspark.api.controller.func;

import cn.bearspark.api.service.func.CollectService;
import cn.bearspark.framework.web.starter.vo.ResponseVO;
import jakarta.validation.constraints.NotNull;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 收藏模块
 *
 * @author f
 */
@Validated
@RestController
@RequestMapping("/collect")
public class CollectController {

    private final CollectService collectService;

    public CollectController(CollectService collectService) {
        this.collectService = collectService;
    }

    /**
     * 收藏/取消收藏专栏
     *
     * @param articleId 待收藏的专栏 id
     * @param collected 是否收藏
     * @return 响应对象
     */
    @PostMapping("/article/{articleId}/{collected}")
    public ResponseVO<Object> collectArticle(@PathVariable Long articleId,
                                             @PathVariable Integer collected) {
        collectService.collectArticle(articleId, collected);
        return ResponseVO.success();
    }

}
